package com.example.smartmallserver.demos.web.controller;

import com.example.smartmallserver.demos.web.pojo.CarouselImage;
import com.example.smartmallserver.demos.web.pojo.Goods;
import com.example.smartmallserver.demos.web.pojo.Navigation;
import com.example.smartmallserver.demos.web.service.IndexService;
import com.example.smartmallserver.demos.web.util.JwUtils;
import com.example.smartmallserver.demos.web.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//@CrossOrigin
@RestController
public class IndexController {
    @Autowired
    IndexService indexService;
    @GetMapping("/page/detail")
    Result indexDetail(){

        List<CarouselImage> carouselImages = indexService.getCarouselImages();
        List<Navigation> navigations = indexService.getNavigations();
        List<Goods> goods = indexService.getGoods();
//        System.out.println("carouselImages:  "+carouselImages);
//        System.out.println("navigations:  "+navigations);
        Map<String,Object> res = new HashMap<>();
        res.put("carouselImages",carouselImages);
        res.put("navigations", navigations);
        res.put("goods", goods);
        System.out.println("res:  "+res);
        return Result.success(res);
    }
}
